import { login } from '@/api/user'
import type { userInfoRequestType, userInfoResponseType } from './types'

export default {
  namespaced: true,
  state: () => ({}),
  mutations: {},
  action: {
    login(userInfo: userInfoRequestType) {
      const { username, password } = userInfo
      return new Promise<userInfoResponseType>((resolve, reject) => {
        login({
          username,
          password,
        })
          .then((data) => {
            if (data) {
              resolve({ success: true, data: {} })
            }
          })
          .catch((error: any) => {
            reject(error)
          })
      })
    },
  },
}
